//
//  AISetInfoAlertView.m
//  MiaMind
//
//  Created by Vill on 2023/12/11.
//

#import "AISetInfoAlertView.h"

@interface AISetInfoAlertView ()

@property (nonatomic, strong) UIView *background;
@property (nonatomic, strong) UIView *container;

@end

@implementation AISetInfoAlertView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self initSubviews];
    }
    return self;
}

- (void)initSubviews {
    [self addSubview:self.background];
    self.background.userInteractionEnabled = YES;
    WeakSelf(self)
    [self.background addTapGestureWithBlock:^(UIGestureRecognizer *gesture) {
        [weakself bgClick];
    }];
    [self addSubview:self.container];
}

-(void)bgClick{
    [self dismiss];
}

- (void)showInView:(UIView * __nullable)view{
    if (view == nil) {
        [[AIUIHelperManager keyWindow] addSubview:self];
    }else {
        [view addSubview:self];
    }
    [UIView animateWithDuration:0.3 animations:^{
        self.container.y = KScreenHeight - PTW(450);
    }];
}

- (void)dismiss {
    [UIView animateWithDuration:0.3 animations:^{
        self.container.y = KScreenHeight;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}



@end
